<?php

/*
 *  Action	$5
 * 
 *  +5 Cards
 *  Discard 3 cards.
 * 
 * When you gain this, each other player gains a Silver.
 */

class Embassy extends Card implements iAction, iKingdom, iHinterlands {

    public function __construct() {
        parent::__construct("Embassy", 5);
    }

    public function getDescription() {
        return array(
            "+5 Cards",
            "Discard 3 cards",
            "When you gain this, each other player gains a Silver"
        );
    }

    public function play(Game $game) {
        // draw
        $drawed_cards = $game->drawCards(5);
        ScreenDisplay::addScreenMessage($game, true, "draw " . nicePrint($drawed_cards), "draws " . sizeof($drawed_cards) . " cards");

        // discard
        $playHand = $game->getPlayHand();
        if (sizeof($playHand) > 3) {
            $discardedCards = MySocket::GetUserReply($game, Input_ChooseMany, $playHand, 3, 3, null, "Choose 3 cards to discard");
            foreach ($discardedCards as $card) {
                $game->moveCardFromPileToPile($card, PlayHand, DiscardPile);
            }
            ScreenDisplay::addScreenMessage($game, false, " and discard " . nicePrint($discardedCards), " and discards " . sizeof($discardedCards) . " cards");
        } else {
            ScreenDisplay::addScreenMessage($game, false, " and discard" . nicePrint($playHand), " and discards " . sizeof($playHand) . " cards");
            $game->discardPlayHand();
        }
        $game->cardActionFinished();
        return true;
    }

    public function gainThisCard(Game $game, $name = null) {
        $otherNames = $game->getOtherPlayersNames(false, $name);
        foreach($otherNames as $o_name) {
            $silver = $game->moveCardFromPileToPile("Silver", BoardCards, DiscardPile, $o_name);
            ScreenDisplay::addScreenMessage($game, true, "gain " .nicePrint( $silver ), "gains " . ScreenDisplay::$LMSG, $o_name);
        }
        $game->setTempCard($this);
        return true;
    }
}

?>